const xhr=new XMLHttpRequest();
const opt={
    method:"GET",
    url:"abc.json",
    callback:()=>{
        if(this.readState !=4){
            return;
        }
        if(this.status==200){
            resolve(this.response)
        }else{
            reject(new Error(this.statusText))
        }
    },
    responseType:"json",
}
//建立链接
xhr.open(opt.method,opt.url);
//设置回调
xhr.onreadystatechange=opt.callback;
//设置响应类型
xhr.responseType=opt.responseType;
//设置请求头
xhr.setRequestHeader("Accept","application/json");

xhr.send();

